package com.henu.xyh;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageButton;

import com.henu.R;

public class WebviewXYHActivity extends AppCompatActivity {

    private WebView webview;
    private ImageButton news_return;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview_xyh);
        webview= (WebView) findViewById(R.id.webview);
        webview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        //支持javascript
        webview.getSettings().setJavaScriptEnabled(true);
// 设置可以支持缩放
        webview.getSettings().setSupportZoom(true);
// 设置出现缩放工具
        webview.getSettings().setBuiltInZoomControls(true);
//扩大比例的缩放
        webview.getSettings().setUseWideViewPort(true);
//自适应屏幕
        webview.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        webview.getSettings().setLoadWithOverviewMode(true);


        webview.getSettings().setTextSize(WebSettings.TextSize.LARGER);


        Intent intent=getIntent();
        if(intent!=null){
            String url=intent.getStringExtra("url");
            webview.loadUrl(url);
            System.out.println(url+"=======================");
        }





        webview.setWebViewClient(new WebViewClient()
        {
            public boolean shouldOverrideUrlLoading(WebView view,String url){
                view.loadUrl(url);
                return  true;
            }
        });

        news_return = (ImageButton) findViewById(R.id.news_return);
        news_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }
}
